import request from '@/utils/request'
// 导入加密后的表格文件
export function importTemplate() {
  const formData = new FormData()
  // 如果 data 已经是 FormData，直接使用
  if (data instanceof FormData) {
    return request({
      url: '/monitor/operlog/importMi',
      method: 'post',
      data: data
    })
  }
  // 如果是普通对象，转换为 FormData
  Object.keys(data).forEach(key => {
    formData.append(key, data[key])
  })
  return request({
    url: '/monitor/operlog/importMi',
    method: 'post',
    data: formData
  })
}
// 导出操作日志列表
export function exportOperlog(params) {
  return request({
    url: '/monitor/operlog/export',
    method: 'get',
    params
  })
}
// 加密导出操作日志列表
export function exportOperlogMi(params) {
  return request({
    url: '/monitor/operlog/exportMi',
    method: 'post',
    params
  })
}
// 获取操作日志列表
export function getOperlogList(params) {
  return request({
    url: '/monitor/operlog/list',
    method: 'get',
    params
  })
}
// 批量删除操作日志
export function delOperlog(operIds) {
  return request({
    url: `/monitor/operlog/${Array.isArray(operIds) ? operIds.join(',') : operIds}`,
    method: 'delete'
  })
}
// 清空操作日志
export function cleanOperlog() {
  return request({
    url: '/monitor/operlog/clean',
    method: 'delete'
  })
}
